package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

//大攻略
@Setter@Getter
public class Strategy extends BaseDomain {
    public static final Integer STATE_NOMAL = 0; //正常
    public static final Integer STATE_DISABLE = 1; //禁用
    public static final Integer STATE_COMMEND = 2; //推荐

    private String title; //攻略标题

    private String subTitle; //副标题

    private String coverUrl; //封面

    private Integer state = STATE_NOMAL; //状态

    private Region place; //区域

    private Integer praiseNum; //点赞个数

    public String getStateName() {
        String msg = "正常";
        if (state == STATE_DISABLE) {
            msg = "禁用";
        } else if (state == STATE_COMMEND) {
            msg = "推荐";
        }
        return msg;
    }

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("subTitle", subTitle);
        map.put("coverUrl", coverUrl);
        map.put("state", state);
        if (place != null) {
            map.put("placeId", place.getId());
        }
        return JSONUtil.toJSONString(map);
    }
}